package com.mc.moring.main;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageButton;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.mc.moring.R;
import com.mc.moring.app.LogUtils;
import com.mc.moring.base.BaseActivity;
import com.mc.moring.bean.MyLoanListBean;
import com.mc.moring.main.adapter.MyLoanDetailsAdapter;
import com.mc.moring.util.GsonUtils;

import java.util.List;

public class MyLoanDetailsActivity extends BaseActivity {
    RecyclerView mRecyclerView;
    private MyLoanDetailsAdapter followAdapter;
    private ImageButton abBackIBtn;
    private TextView abTitleTV;
    private MyLoanListBean.dataBean bean;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LogUtils.logE("loan detail page");
        setContentView(R.layout.activity_loan_details);
        bean = (MyLoanListBean.dataBean) getIntent().getSerializableExtra("_bean");
        LogUtils.logE(GsonUtils.INSTANCE.getGson().toJson(bean));
        List<MyLoanListBean.loanListBean> arrayList = bean.getLoanList();
        for( int i = 0; i < arrayList.size(); i++ ){
            if ( arrayList.get(i).getLendOutTime() == null || arrayList.get(i).getLendOutTime().isEmpty()){
                arrayList.get(i).setLendOutTime("0");
            }
        }
        mRecyclerView = findViewById(R.id.recycler_view);
        abBackIBtn = findViewById(R.id.abBackIBtn);
        abTitleTV = findViewById(R.id.abTitleTV);
        abTitleTV.setText("Detalles");
        mRecyclerView.setLayoutManager(new LinearLayoutManager(MyLoanDetailsActivity.this));
        followAdapter = new MyLoanDetailsAdapter();
        mRecyclerView.setAdapter(followAdapter);
        abBackIBtn.setOnClickListener(v -> finish());
        followAdapter.replaceData(bean.getLoanList());
    }

    @Override
    public Activity getActivity() {
        return null;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {

    }
}
